package lanqiao;
/**
 * @Project : AlgorithmLearning
 * @Package : LanQiao.PrepareForCompetition
 * @File : Q2378.java
 * @Author : WangRuoyu
 * @Date : 2023/3/30 14:12
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Q2378 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] words = br.readLine().split(" ");
        int n = Integer.parseInt(words[0]);
        int res = 0;
        for (int i = 1; i <= n - 1; ++i) {
            if (i * i % n < n / 2.0) {
                res++;
            }
        }
        System.out.println(res);
    }
}
